<div class="content-section introduction">
    <div>
        <span class="feature-title">RadioButton</span>
        <span>RadioButton is an extension to standard radio button element with skinning capabilities.</span>
    </div>
</div>

<div class="content-section implementation">
    <h3 class="first">Basic</h3>
    <div class="ui-g" style="width:250px;margin-bottom:10px">
        <div class="ui-g-12"><p-radioButton name="group1" value="Option 1" label="Option 1" [(ngModel)]="val1"></p-radioButton></div>
        <div class="ui-g-12"><p-radioButton name="group1" value="Option 2" label="Option 2" [(ngModel)]="val1"></p-radioButton></div>
        <div class="ui-g-12"><p-radioButton name="group1" value="Option 3" label="Option 3" [(ngModel)]="val1"></p-radioButton></div>
    </div>
    Selected Value = {{val1||'none'}}

    <h3>Preselection</h3>
    <div class="ui-g" style="width:250px;margin-bottom:10px">
        <div class="ui-g-12"><p-radioButton name="group2" value="Option 1" label="Option 1" [(ngModel)]="val2"></p-radioButton></div>
        <div class="ui-g-12"><p-radioButton name="group2" value="Option 2" label="Option 2" [(ngModel)]="val2"></p-radioButton></div>
        <div class="ui-g-12"><p-radioButton name="group2" value="Option 3" label="Option 3" [(ngModel)]="val2"></p-radioButton></div>
    </div>
    Selected Value = {{val2||'none'}}
</div>

<div class="content-section documentation">
    <p-tabView effect="fade">
        <p-tabPanel header="Documentation">
            <h3>Import</h3>
<pre>
<code class="language-typescript" pCode ngNonBindable>
import &#123;RadioButtonModule&#125; from 'primeng/primeng';
</code>
</pre>

            <h3>Getting Started</h3>
            <p>Two-way value binding is defined using the standard ngModel directive.</p>
            
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-radioButton name="groupname" value="val1" [(ngModel)]="selectedValue"&gt;&lt;/p-radioButton&gt;
&lt;p-radioButton name="groupname" value="val2" [(ngModel)]="selectedValue"&gt;&lt;/p-radioButton&gt;
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class ModelComponent &#123;

    selectedValue: string;

&#125;
</code>
</pre>

            <p>As model is two-way binding enabled, giving a default value to the model is enough to display a radio button as checked by default.</p>
<pre>
<code class="language-typescript" pCode ngNonBindable>
export class ModelComponent &#123;

    selectedValue: string = 'val1';

&#125;
</code>
</pre>

            <h3>Model Driven Forms</h3>
            <p>RadioButton can be used in a model driven form as well.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-radioButton name="groupname" value="ps4" formControlName="console"&gt;&lt;/p-radioButton&gt;
</code>
</pre>

            <h4>Label</h4>
            <p>The label attribute provides a label text for the radio button. This label is also clickable and selects value.</p>
            <pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-radioButton name="groupname" value="val1" label="Option 2" [(ngModel)]="selectedValue"&gt;&lt;/p-radioButton&gt;
</code>
            </pre>

            <h3>Properties</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>name</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Name of the radiobutton group.</td>
                        </tr>
                        <tr>
                            <td>value</td>
                            <td>any</td>
                            <td>null</td>
                            <td>Value of the radiobutton.</td>
                        </tr>
                        <tr>
                            <td>label</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Label of the radiobutton.</td>
                        </tr>
                        <tr>
                            <td>disabled</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that the element should be disabled.</td>
                        </tr>
                        <tr>
                            <td>tabindex</td>
                            <td>number</td>
                            <td>null</td>
                            <td>Index of the element in tabbing order.</td>
                        </tr>
                        <tr>
                            <td>inputId</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Identifier of the focus input to match a label defined for the component.</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>object</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Events</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>onClick</td>
                            <td>-</td>
                            <td>Callback to invoke on radio button click.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Styling</h3>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Element</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>ui-radiobutton</td>
                            <td>Container element</td>
                        </tr>
                        <tr>
                            <td>ui-radiobutton-box</td>
                            <td>Container of icon.</td>
                        </tr>
                        <tr>
                            <td>ui-radiobutton-icon</td>
                            <td>Icon element.</td>
                        </tr>
                        <tr>
                            <td>ui-chkbox-label</td>
                            <td>Label element.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Dependencies</h3>
            <p>None.</p>
            
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/radiobutton" class="btn-viewsource" target="_blank">
                <i class="fa fa-github"></i>
                <span>View on GitHub</span>
            </a>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;h3 class="first"&gt;Basic&lt;/h3&gt;
&lt;div class="ui-g" style="width:250px;margin-bottom:10px"&gt;
    &lt;div class="ui-g-12"&gt;&lt;p-radioButton name="group1" value="Option 1" label="Option 1" [(ngModel)]="val1"&gt;&lt;/p-radioButton&gt;&lt;/div&gt;
    &lt;div class="ui-g-12"&gt;&lt;p-radioButton name="group1" value="Option 2" label="Option 2" [(ngModel)]="val1"&gt;&lt;/p-radioButton&gt;&lt;/div&gt;
    &lt;div class="ui-g-12"&gt;&lt;p-radioButton name="group1" value="Option 3" label="Option 3" [(ngModel)]="val1"&gt;&lt;/p-radioButton&gt;&lt;/div&gt;
&lt;/div&gt;
Selected Value = {{val1||'none'}}

&lt;h3&gt;Preselection&lt;/h3&gt;
&lt;div class="ui-g" style="width:250px;margin-bottom:10px"&gt;
    &lt;div class="ui-g-12"&gt;&lt;p-radioButton name="group2" value="Option 1" label="Option 1" [(ngModel)]="val2"&gt;&lt;/p-radioButton&gt;&lt;/div&gt;
    &lt;div class="ui-g-12"&gt;&lt;p-radioButton name="group2" value="Option 2" label="Option 2" [(ngModel)]="val2"&gt;&lt;/p-radioButton&gt;&lt;/div&gt;
    &lt;div class="ui-g-12"&gt;&lt;p-radioButton name="group2" value="Option 3" label="Option 3" [(ngModel)]="val2"&gt;&lt;/p-radioButton&gt;&lt;/div&gt;
&lt;/div&gt;
Selected Value = {{val2||'none'}}
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class RadioButtonDemo &#123;

    val1: string;

    val2: string = 'Option 2';
    
&#125;
</code>
</pre>
        </p-tabPanel>
    </p-tabView>
</div>